package 力扣日常刷题.木22二月.第16天222;

import 力扣日常刷题.ListNode;

/**
 * @author 帅小伙
 * @date 2022/2/22
 * @description
 */
public class Demo130获取链表的中间节点 {


    public ListNode middleNode (ListNode head) {
        ListNode slow = head;
        ListNode fast = head;

        while (fast!=null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }
        return slow;
    }
}
